#ifndef RECORDTHREAD_H
#define RECORDTHREAD_H

#include <QWidget>
#include <QThread>
#include <RtAudio.h>
#include <vector>



class RecordThread : public QThread
{
    Q_OBJECT
public:
    enum Types
    {
        TOMCAT = 0,
        MINIONS,
        NONE,
    };
    enum PlayTypes
    {
        RECORD = 0,
        REALTIME,
    };
 signals:
    void recordOver(void);
    void recordPlayOver(void);
public:
    std::vector<short> m_RecordData;
    bool m_isplay;
    int m_recordPlayIndex;
    bool m_RecordEnable;

public:
    explicit RecordThread(QWidget *parent = NULL);
    static int record(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void *userData);
    void stop();
    static void pitchShift(short *input, short *output, int totalsize, int sampleRate, Types type, float PitchShift);
    Types GetType(){return m_type;}
    void setType(Types type) {m_type = type;}
    float GetPitchShift(){return m_pitchShift;}
    void setPitchShift(float pitchshift){m_pitchShift = pitchshift;}

    PlayTypes GetPlayType(){return m_playType;}
    void setPlayType(PlayTypes type){m_playType = type;}
    void recordEnable();
    void recordEnablePlay();
protected:
    virtual void run();

private:
    RtAudio adc;
    RtAudio::StreamParameters input;
    RtAudio::StreamParameters output;

    Types m_type;
    PlayTypes m_playType;
    float m_pitchShift;



};

#endif // RECORDTHREAD_H
